//新建formData
export function configForm () {
  return[
    {
      fieldName: '编码',//title
      field: 'code',  //key
      value: '',
      type: 'input',
      placeholder: '请输入内容',
      disabled: true,
      rules:[
            { required: true, message: '编码不能为空', trigger: 'blur' }
          ]
    },
    {
      fieldName: '业务规则标题',
      field: 'title',
      value: '',
      type: 'input',
      placeholder: '请输入内容',
     rules:[{ required: true, message: '标题不能为空', trigger: 'blur' }]
    },
    {
      fieldName: '业务主题域',
      field: 'dataSubject',
      value: '',
      type: 'input',
      placeholder: '请输入内容',
      rules:[{ required: true, message: '业务主题域不能为空', trigger: 'blur' }]
    },
    {
      fieldName: '关联功能模块',
      field: 'functionModules',
      value: '',
      type: 'input',
      placeholder: '请输入内容',
      rules:[{ required: true, message: '关联功能模块不能为空', trigger: 'blur' }]
    },
    {
      fieldName: '关联数据项名称',
      field: 'dataItemName',
      value: '',
      type: 'input',
      placeholder: '请输入内容',
      rules:[{ required: true, message: '关联数据项名称不能为空', trigger: 'blur' }]
    },
    {
      fieldName: '业务单元',
      field: 'profitCenter',
      value: '',
      type: 'select',
      placeholder: '请选择业务单元',
      optionList: this.optionListUnit,
      // optionList:this.crsrm_purchaser_sbu,
      rules:[{ required: true, message: '请选择业务单位', trigger: 'blur' }]
    },
    {
      fieldName: '规则状态',
      field: 'state',
      value: '',
      type: 'select',
      placeholder: '请输入规则状态',
      optionList: this.crsrm_default_state,
      rules:[{ required: true, message: '请选择状态', trigger: 'blur' }]
    },
    {
      fieldName: '流程状态',
      field: 'bpmnState',
      value: '',
      type: 'select',
      placeholder: '请选择流程状态',
      optionList: this.crsrm_rule_bpmn_state,
      disabled:true
    },

    {
      fieldName: '业务规则描述',
      field: 'describes',
      value: '',
      type: 'textarea',
      placeholder: '请输入内容',
      rules:[{ required: true, message: '规则描述不能为空', trigger: 'blur' }]
    },
    // {
    //   fieldName: '所属系统',
    //   field: '',
    //   value: '',
    //   type: 'input',
    //   placeholder: '请输入内容',

    // },
    // {
    //   fieldName: '创建人',
    //   field: 'createUserId',
    //   value: '',
    //   type: 'input',
    //   placeholder: '请输入内容',

    // },
    // {
    //   fieldName: '创建时间',
    //   field: 'createTime',
    //   value: '',
    //   type: 'date',
    //   placeholder: '请输入内容',

    // },
    // {
    //   fieldName: '变更人',
    //   field: 'updateUserId',
    //   value: '',
    //   type: 'input',
    //   placeholder: '请输入内容',

    // },
    // {
    //   fieldName: '变更时间',
    //   field: 'updateTime',
    //   value: '',
    //   type: 'date',
    //   placeholder: '请输入内容',

    // },

  ]
}

export function formData() {
  return [
    {
      fieldName: "主表编码",
      field: 'groupCode',
      value: '',
      type: 'input',
      placeholder: '请输入内容',
      disabled: true,
      rules:[
        { required: true, message: '主表编码不能为空', trigger: 'blur' }
      ]
    },
    {
      fieldName:"规则标题",
      field: 'title',
      value: '',
      type: 'input',
      placeholder: '请输入内容',
      rules:[
        { required: true, message: '规则标题不能为空', trigger: 'blur' }
      ]
    },
    {
      fieldName: "校验表名",
      field: 'ruleTableName',
      value: '',
      type: 'input',
      placeholder: '请输入内容',
      rules:[
        { required: true, message: '校验表名不能为空', trigger: 'blur' }
      ]
    },
    {
      fieldName: "标识字段",
      field: 'ruleIdentifyColumn',
      value: '',
      type: 'input',
      placeholder: '请输入内容',
      rules:[
        { required: true, message: '标识字段不能为空', trigger: 'blur' }
      ]
    },
    {
      fieldName: '规则状态',
      field: 'state',
      value: '',
      type: 'select',
      placeholder: '请选择规则状态',
      optionList: this.crsrm_default_state,
      rules:[{ required: true, message: '请选择状态', trigger: 'change' }]
    },
    {
      fieldName: '校验类型',
      field: 'checkType',
      value: '',
      type: 'select',
      placeholder: '请选择校验类型',
      optionList: this.crsrm_rule_check_type,
      rules:[{ required: true, message: '请选择校验类型', trigger: 'change' }]
    },
    {
      fieldName: '标签',
      field: 'label',
      value: '',
      type: 'select',
      placeholder: '请选择校验类型',
      optionList: this.crsrm_rule_label,
      rules:[{ required: true, message: '请选择标签', trigger: 'change' }]
    },
    {
      fieldName: '规则逻辑描述',
      field: 'describes',
      value: '',
      type: 'textarea',
      placeholder: '请输入内容',
      rules:[{ required: true, message: '规则逻辑描述不能为空', trigger: 'blur' }]
    },
    {
      fieldName: '异常模板',
      field: 'ruleMessageTemplate',
      value: '',
      type: 'textarea',
      placeholder: '请输入内容',
      rules:[{ required: true, message: '异常模板不能为空', trigger: 'blur' }]
    },
    {
      fieldName: '规则',
      field: 'ruleSql',
      value: '',
      type: 'textarea',
      placeholder: '请输入内容',
      rules:[{ required: true, message: '规则不能为空', trigger: 'blur' }]
    },
    // {
    //   fieldName: '创建人',
    //   field: 'createUserId',
    //   value: '',
    //   type: 'input',
    //   placeholder: '请输入内容',

    // },
    // {
    //   fieldName: '创建时间',
    //   field: 'createTime',
    //   value: '',
    //   type: 'date',
    //   placeholder: '请输入内容',

    // },
    // {
    //   fieldName: '变更人',
    //   field: 'updateUserId',
    //   value: '',
    //   type: 'input',
    //   placeholder: '请输入内容',

    // },
    // {
    //   fieldName: '变更时间',
    //   field: 'updateTime',
    //   value: '',
    //   type: 'date',
    //   placeholder: '请输入内容',

    // },
  ]
}

export function generateColumns() {
  return [
    {
      type: "selection",
      // key:"#",
      width:45,
      align: "center",
      fixed: "left",
    },
    {
      title: '编码',
      key: "code",
      width: 185,
      resizable:true
    },
    {
      title: '标题',
      key: "title",
      width: 185,
      resizable:true
    },
    {
      title: '表名',
      key: "ruleTableName",
      width: 185,
      resizable:true
    },
    {
      title: '标识列',
      key: "ruleIdentifyColumn",
      width: 185,
      resizable:true
    },
    {
      title: '校验类型',
      width: 125,
      resizable:true,
      key: 'checkType',
      render: (h, { row }) => {
        return this.checkTypeHandle(h, row)
      }
    },
    {
      title: '标签',
      width: 125,
      resizable:true,
      key: 'labelStr',
      // render: (h, { row }) => {
      //   return this.label_Handle(h, row)
      // }
    },
    {
      title: '创建人',
      key: 'createUserName',
      // width: 125,
      // resizable:true
    },
    {
      title: '创建时间',
      key: "createTime",
      width: 185,
      resizable:true
    },
    {
      title: '变更人',
      key: 'updateUserName',
      // width: 125,
      // resizable:true
    },
    {
      title: '变更时间',
      key: 'updateTime',
      width: 185,
      resizable:true
    },
    {
      title: '操作',
      align: "center",
      fixed: "right",
      width: 60,
      // resizable:true,
      render: (h, { row }) => {
        return h("RowTools", {
          props: {
            data: [
              {
                type: 'icon',
                  icon: 'md-eye',
                  text: '查看',
                handle: () => this.detailHandle(row )
              },
              // {
              //   // type: "icon",
              //   // icon: "md-create",
              //   text: "删除",
              //   handle: () => this.deleteHandler(row)
              // }
            ]
          }
        });
      }
    }
  ];
}

export const detailField = {
  code: "规则编码",
  title:"规则标题",
  rule_table_name: "被校验表名",
  rule_identify_coulmn: "标识字段名称",
  rule_describe: "规则逻辑描述",
  rule_sql: "数据规则",
  rule_message_template: "异常模板",
  groupc_code: "主表code",
	create_user: "创建人",
  update_user: "更变人",
  create_time: "创建时间",
  update_time: "更新时间",

}


export const ruleValidate = {
  code: [
    { required: true, message: '编码不能为空', trigger: 'blur' }
  ],
  title:[
    { required: true, message: '标题不能为空', trigger: 'blur' }
  ],
  dataSubject: [
    { required: true, message: '业务主题域不能为空', trigger: 'blur' }
  ],
  functionModules:[
    { required: true, message: '关联功能模块不能为空', trigger: 'blur' }
  ],
  dataItemName: [
    { required: true, message: '关联数据项名称不能为空', trigger: 'blur' }
  ],

  profitCenter:[
    { required: true, message: '请选择业务单位', trigger: 'change' }
  ],
  state:[
    { required: true, message: '请选择状态', trigger: 'change' }
  ],
  describes:[
    { required: true, message: '规则描述不能为空', trigger: 'blur' }
  ],

}
